package com.jie.component.lock.config;

import com.jie.common.util.LogUtil;
import com.jie.component.lock.aspect.RepeatExecuteLimitAspect;
import com.jie.component.lock.core.ManageLocker;
import com.jie.component.lock.factory.ServiceLockFactory;
import com.jie.component.lock.lockinfo.LockInfoHandle;
import com.jie.component.lock.lockinfo.LockInfoType;
import com.jie.component.lock.lockinfo.factory.LockInfoHandleFactory;
import com.jie.component.lock.lockinfo.impl.RepeatExecuteLimitLockInfoHandle;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @author jie
 * @version 1.0 2025-02-12
 */
public class RepeatExecuteLimitAutoConfiguration {

    @Bean(LockInfoType.REPEAT_EXECUTE_LIMIT)
    public LockInfoHandle repeatExecuteLimitHandle(){
        LogUtil.autoConfigLog("LockInfoHandle");
        return new RepeatExecuteLimitLockInfoHandle();
    }

    @Bean
    public RepeatExecuteLimitAspect repeatExecuteLimitAspect(ManageLocker manageLocker,
                                                             StringRedisTemplate stringRedisTemplate,
                                                             ServiceLockFactory serviceLockFactory,
                                                             LockInfoHandleFactory lockInfoHandleFactory) {
        LogUtil.autoConfigLog("RepeatExecuteLimitAspect");
        return new RepeatExecuteLimitAspect(manageLocker, serviceLockFactory, stringRedisTemplate, lockInfoHandleFactory);
    }
}
